<template>
  <div class="idea">
    <!-- 用户信息 -->
    <van-row class="idea-user" type="flex" justify="start" align="center">
      <van-col span="3" class="image" @click.stop="toUserindex">
        <van-image :src="user.image" round width="30px" height="30px"></van-image>
      </van-col>
      <van-col span="10">
        <div class="auther" @click.stop="toUserindex">{{user.name}}</div>
        <div class="time">{{time}}</div>
      </van-col>
    </van-row>
    <!-- 文本内容 -->
    <div class="idea-text"></div>
    <!-- 图片内容 -->
    <div class="idea-image">
      <van-grid :border="false" :column-num="3">
        <van-grid-item v-for="(image,index) in images" :key="index">
          <van-image :src="image" />
        </van-grid-item>
      </van-grid>
    </div>
    <!-- 底部 -->
    <div class="idea-footer">{{likecount}}赞·{{commentcount}}评论</div>
    <van-icon name="ellipsis" size="22px" @click.stop="showOperation" />
    <operation-box class="operation" v-if="operate_show"></operation-box>
  </div>
</template>

<script>
import time from "@/common/time";
import utils from "@/common/utils";
import operationbox from "../Popup/topic-operate";
export default {
  name: "idea-card",
  props: {
    user: {
      type: Object,
      require: true,
    },
    topic: {
      type: Object,
      require: true,
    },
  },
  data() {
    return {
      operate_show: false,
    };
  },
  methods: {
    toUserindex() {
      this.$router.push({
        path: "/account/userindex",
        query: { user: this.user.name },
      });
    },
    showOperation() {
      this.operate_show = true;
    },
  },
  computed: {
    time() {
      return time.timeshow(this.topic.time);
    },
    likecount() {
      return utils.numberShow(this.topic.likecount);
    },
    commentcount() {
      return utils.numberShow(this.topic.commentcount);
    },
    images() {
      return [
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
        "http://pic.52112.com/180623/JPG-180623A_204/3TbalZMx4p_small.jpg",
      ];
    },
  },
  mounted() {},
  components: {
    "operation-box": operationbox,
  },
};
</script>

<style>
.idea {
  position: relative;
  background: #fff;
  margin-bottom: 10px;
  border-radius: 10px;
  box-shadow: 3px 3px 5px 0px #97979759;
}
.idea-user {
  text-align: left;
  padding-top: 10px;
}
.idea-user .auther {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  color: #404040eb;
}
.idea-user .time {
  font-size: 12px;
  color: #909090;
}
.idea-user .image {
  text-align: center;
}
.idea-text {
  color: #979797;
  font-size: 13px;
  min-width: 80%;
  padding-right: 10px;
  text-align: left;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  min-height: 20px;
  padding-top: 5px;
}
.idea-footer {
  text-align: left;
  font-size: 12px;
  padding: 8px;
  color: #909090;
}
.idea .van-icon {
  position: absolute;
  right: 15px;
  top: 10px;
  color: #4994e5;
}
.idea .van-grid .van-grid-item__content {
  padding: 4px;
}
.idea .van-grid img {
  width: 110px;
  height: 110px;
  object-fit: cover;
}
</style>